
@extends('layouts.master3')
@section('title')
{{"设置"}}
@stop

@section('css')
<link href="/css/user_update.css" rel="stylesheet">
@stop

@section('content')
<?php
use App\Utils;
$arr=explode("|",Auth::user()->location);
if(count($arr)<2)
{
  $pro="-请选择-";
  $city="-请选择-";
}
else
{
   $pro=$arr[0];
   $city=$arr[1];
}
?>


<!-- Latest compiled JavaScript -->
<div class="contain">
<?= Form::open(['url' => action('UsersController@index'), 'method' => 'POST', 'files' => true]) ?>
  <div class="container">
    <div class="row">
      <div class="col-md-9">
        <div class="panel panel-default">
          <div class="panel-body">
            <div class="row">
              <div class="col-md-12 lead">
                设置
		<small><font color="red">{{$message or ""}}</font></small>
                <hr>
              </div>
            </div>
            <div class="row">
              <div class="col-md-3 text-center">
                <div id="img-preview-block"  class="img-circle avatar avatar-original center-block" style="background-size:cover;background-image:url({{Auth::user()->avatar->url() }})"> </div>
                <br> 
                <span class="btn btn-link btn-file">更改头像 <input id="upload-img" name="avatar" type="file"></span>
              </div>
              <div class="col-md-9">
                <div class="form-group">
                </div>
	  <div class="form-group">
                  <label for="user_email">邮箱</label>
                  <div class="clear"></div>
                  <input class="form-control" id="user_email" name="email" disabled type="text" value="{{Auth::user()->email}}">
                  <?php
                    if(Auth::user()->active==0){
                      ?>
                      <span><i class="iconfont">&#xe616;</i>未验证</span>
                      <a class="re_send" href="javascript:;"><span></span>重新发送</a>
                      <?php
                    }
                    else{
                      ?>
                        <span><i class="iconfont check_pass">&#xe617;</i>已验证</span>
                      <?php
                    }
                  ?>
                </div>

                <div class="form-group">
                  <label for="user_nick">昵称</label>
                  <div class="clear"></div>
                  <input class="form-control" id="user_nick" name="name" type="text" value="{{Auth::user()->name}}">
                  <span class="nick_length none"><i class="iconfont">&#xe616;</i>用户名长度为1-16位</span>
                </div>
                <div class="form-group">
                  <label for="user_introduce">一句话介绍自己</label>
                  <div class="clear"></div>
                  <input class="form-control" id="user_introduce" name="introduce" type="text" value="{{Auth::user()->introduce}}">
                </div>
                <div class="form-group">
                  <label for="user_company">公司</label>
                  <div class="clear"></div>
                  <input class="form-control" id="user_company" name="company" type="text" value="{{Auth::user()->company}}">
                </div>
                <div class="form-group">
                  <label for="user_job">技术方向</label>
                  <div class="clear"></div>
                  <input class="form-control" id="user_job" name="title" type="text" value="{{Auth::user()->title}}">
                </div>
		<div class="form-group">
		<label>所在地</label>
<div class="row">
<div class="col-sm-4">
<select class="form-control"  id="pro" name="pro">
    	<option>{{$pro}}</option>
        <option>北京市</option>
        <option>上海市</option>
        <option>天津市</option>
        <option>重庆市</option>
        <option>河北省</option>
        <option>山西省</option>
        <option>内蒙古自治区</option>
        <option>辽宁省</option>
        <option>吉林省</option>
        <option>黑龙江省</option>
        <option>江苏省</option>
        <option>浙江省</option>
        <option>安徽省</option>
        <option>福建省</option>
        <option>江西省</option>
        <option>山东省</option>
        <option>河南省</option>
        <option>湖北省</option>
        <option>湖南省</option>
        <option>广东省</option>
        <option>广西壮族自治区</option>
        <option>海南省</option>
        <option>四川省</option>
        <option>贵州省</option>
        <option>云南省</option>
        <option>西藏自治区</option>
        <option>陕西省</option>
        <option>甘肃省</option>
        <option>宁夏回族自治区</option>
        <option>青海省</option>
        <option>新疆维吾尔族自治区</option>
        <option>香港特别行政区</option>
        <option>澳门特别行政区</option>
        <option>台湾省</option>
        <option>其它</option>
    </select>
</div>
<div class="col-sm-4">
    <select class="form-control"  id="city" name="city">
		<option>{{$city}}</option>
	 </select>
</div>
</div>
		</div>
              <!--  <div class="radio">
                  <label class="radio-inline">
                    <input value="male" checked="checked" name="user[gender]" id="user_gender_male" type="radio">Мужской
                  </label>
                  <label class="radio-inline">
                    <input value="female" name="user[gender]" id="user_gender_female" type="radio">Женский
                  </label>
                  <label class="radio-inline">
                    <input value="other" name="user[gender]" id="user_gender_other" type="radio">Другое
                  </label>
                </div> -->
                
                
              </div>
            </div>
            <div class="row">
              <div class="col-md-12">
                <hr>
                <button class="btn btn-primary btn_save pull-right" style="margin-right: 50px;"><i class="glyphicon glyphicon-floppy-disk"></i> 保存</button>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="col-md-3">
            <div class="well">
                <h4>奥利奥说：</h4>
                <p style="text-indent: 2em;">
                    <strong>完善基本资料</strong>，将便于coder之间的交流，以及后期各个公司大牛一对一沟通。当其他coder访问您的<a target="_blank" href="/profile/{{Utils::id2url(Auth::user()->id)}}">个人主页</a>，可以更方便的了解你。
                </p>
                <p style="text-indent: 2em;">
                    通过<strong>完善基本资料</strong>，您可获取 3 <a href="http://www.qlcoder.com/help">跬步</a>，跬步可在千里码社区兑换<strong>机械键盘——ikbc poker3</strong>
                </p>
            </div>
        </div>
    </div>
  </div>
  <div id="delete-user-modal" class="modal fade">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-body">
          <p>Are you sure you want to delete account?</p>
        </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
  </div><!-- /.modal -->
<?= Form::close() ?>
   </div>     


        
        <!-- JavaScript jQuery code from Bootply.com editor  -->
        
@stop
@section("js")
<script src="/js/city.js"></script>
        <script type='text/javascript'>
        
        $(function(){
              var v_flag=$("#user_nick").val().length;
              if(v_flag>0&&v_flag<17){
                  $(".nick_length").removeClass("none").html('<i class="iconfont check_pass">&#xe617;</i>');
              }
              $("#user_nick").focus(function(){
                  var _this=this;
                  $(_this).bind("input propertychange",function(){
                      var _val=$(this).val();
                      var size=$(this).val().length;
                      console.log(size);
                      if(size<1||size>16){
                          $(".nick_length").removeClass("none").html('<i class="iconfont">&#xe616;</i>用户名长度为1-16位');
                          $(this).css("border-color","red");
                          $(".btn_save").attr("disabled","true");
                      }
                      else{
                          $(".nick_length").removeClass("none").html('<i class="iconfont check_pass">&#xe617;</i>');
                          $(this).removeAttr("style");
                          $(".btn_save").removeAttr("disabled");
                      }
                      $(this).attr("value",_val);
                  })
              }).blur(function(){
                  var _vlue=$(this).val();
                  if(_vlue==""||_vlue==null){
                      $(".nick_length").html('<i class="iconfont">&#xe616;</i>用户名长度为1-16位');
                  }
              });


              $(".re_send").bind("click",function(){
                  $.get("http://www.qlcoder.com/sendmail",{},function(data){
                      console.log(data);
                  });
                  $(this).html("<span>60</span>S后重新发送");
                  var __time=$(this).children("span").html();
                  setTimeout(function(){wait(60);},0);
              })

          });

          function wait(d){
              $(".re_send").css({"cursor":"none","color":"gray"});
              var t=d;
              if(t>=1){
                  t--;
                  $(".re_send span").html(t);
                  setTimeout(function(){wait(t)},1000);
              }
              else{
                  $(".re_send").html("重新发送").removeAttr("style").css({"cursor":"pointer"});
                  return !1;
              }
          }
          //thumb user avatar @diego 16.4.8
          var
                  fileInput = document.getElementById('upload-img'),
                  preview = document.getElementById('img-preview-block');
          // 监听change事件:
          fileInput.addEventListener('change', function () {
              // 清除背景图片:
              //preview.style.backgroundImage = '';
              // 检查文件是否选择:
              if (!fileInput.value) {
                  alert('没有选择文件');
                  return;
              }
              // 获取File引用:
              var file = fileInput.files[0];
              // 获取File信息:

              if (file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') {
            //      alert('不是有效的图片文件!');
              //    return;
              }
              // 读取文件:
              var reader = new FileReader();
              reader.onload = function(e) {
                  var
                          data = e.target.result; // '...(base64编码)...'
                  preview.style.backgroundImage = 'url(' + data + ')';
              };
              // 以DataURL的形式读取文件:
              reader.readAsDataURL(file);
          });
        
        </script>
        

@endsection
